using EnumDefine;
using UnityEngine;

public class LogicBase : MonoBehaviour
{

    public void DoRelease()
    {
        GameObject.Destroy(this);
    }

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }
    void Update()
    {

    }

    Camera GetMainCamera()
    {
        return Camera.main;
    }
    
    protected GameObject m_Select;

    Vector2 m_Zero;

    public Vector3 m_CameraPos;

    // Update is called once per frame

    float GetSceneMoveSpeed()
    {
        return GetMainCamera().orthographicSize / 10;
    }
    public virtual void DoUpdate()
    {

        if (Input.GetMouseButtonDown(1))
        {
            m_Zero = Input.mousePosition;
        }
        if (Input.GetMouseButton(1))
        {
            m_CameraPos -= (Input.mousePosition - (Vector3)m_Zero) * GetSceneMoveSpeed() * Time.deltaTime;
            m_CameraPos.z = -10;
            GetMainCamera().transform.position = m_CameraPos;
            m_Zero = Input.mousePosition;
        }
        if (Input.GetMouseButtonUp(1))
        {

        }


        if (Input.mouseScrollDelta.y != 0)
        {
            var camera = GetMainCamera();
            float scorll = camera.orthographicSize - Input.mouseScrollDelta.y * 10 * Time.deltaTime;
            if (scorll < 10)
                scorll = 10;
            if (scorll > 15)
                scorll = 15;
            camera.orthographicSize = scorll;
        }
    }
}
